<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>外出申请审核设置</title>
<script type="text/javascript">
$(document).ready(function(){
	$('#programform').vaildAjax(function(data){
		if(data.charAt(0) =='a'){
			$('input[name="a2u.id"]').val(data.substring(1));
			var tr = '<tr id="exp'+data.substring(1)+'"><td><input type="radio" checked="checked" class="opera" name="opera" value="'+data.substring(1)+'" /></td>';
			tr+='<td>'+$('select[name="a2u.programe"]').sltTxt()+'</td>';
			tr+='<td>'+$('select[name="a2u.audit.id"]').sltTxt()+'</td>';
			tr+='<td>'+($('input[name="a2u.enable"]').radio()=='true'?'可用':'禁用')+'</td>'
			$('table.list').append(tr);
			BaseJs.alert('添加成功');
		}else if(data.charAt(0) =='u'){
			var tds = $('#exp'+data.substring(1)+" td");
			var seltxt = $('select[name="a2u.programe"]').sltTxt();
			if(seltxt==''){
				seltxt = $('#pd').text();
			}
			$(tds[1]).text(seltxt);
			$(tds[2]).text($('select[name="a2u.audit.id"]').sltTxt());
			$(tds[3]).text($('input[name="a2u.enable"]').radio()=='true'?'可用':'禁用');
			BaseJs.alert('修改信息成功');
		}else{
			BaseJs.alert(data,'error');
		}
	});
	<s:if test="a2u==null" >
		$('input[name="a2u.enable"]').radio('true');
	</s:if>
	$('.opera').click(function(){
		var tds = $('#exp'+$(this).val()+' td');
		$('input[name="a2u.id"]').val($(this).val());
		$('#pd').html($(tds[1]).text()+'<input type="hidden" value="'+$(this).attr('pid')+'" name="a2u.programe" />');
		$('select[name="a2u.audit.id"]').selcByTxt($(tds[2]).text());
		$('input[name="a2u.enable"]').radio($(tds[3]).text()=='可用'?'true':'false');
	});
	$('select[name="a2u.programe"]').change(function(){
		var pid = $(this).val();
		if(pid != ''){
			$.urlAjax('aduitor/ListAduitor!cheak?a2u.programe='+pid,function(data){
				if(data!=""){
					$('input[name="a2u.id"]').val(data.id);
					$('select[name="a2u.audit.id"]').selcByTxt(data.audit.name);
				}else{
					$('input[name="a2u.id"]').val('');
				}
			});
		}
	});
});
</script>
</head>
<body>
<h2 class="title"><span>外出申请审核设置</span><m:imgA img="add" msg="新加栏目审核" onclick="javascript:BaseJs.reload();" /></h2>
<s:form id="programform" action="aduitor/ListAduitor!save">
	<s:hidden name="a2u.id" />
	<table class="form">
		<tr>
			<th width="20%">栏目名称</th>
			<td width="30%" id="pd"><m:select enumType="program.type" name="a2u.programe" /></td>
			<th width="20%">审核人员</th>
			<td width="30%"><m:dropUser name="a2u.audit.id" headKey="--请选择--"  headValue="" cssClass="rule[required]" /></td>
		</tr>
		<tr>
			<th>状态</th>
			<td colspan="3"><s:radio list="#{true:'可用','false':'禁用'}" name="a2u.enable" cssClass="rule[required]" ></s:radio> </td>
		</tr>
	</table>
	<div class="btnGroup"><s:submit value="保存" /></div>
</s:form>

<table class="list">
	<tr>
		<th width="30%">操作</th>
		<th width="30%">栏目名称</th>
		<th width="30%">审核人员</th>
		<th width="10%">状态</th>
	</tr>
	<s:iterator value="aditors.items">
		<tr id="exp${id}">
			<td><input type="radio" value="${id}"  pid="${programe}"  name="opera" class="opera" ></td>
			<td><m:property value="programe"/> </td>
			<td><s:property value="audit.name" />(<s:property value="audit.nickName" />)</td>
			<td><s:if test="enable">可用</s:if><s:else>禁用</s:else></td>
		</tr>
	</s:iterator>
</table>
<m:page value="${aditors}"/>
</body>
</html>